//
//  FBtnArrow.m
//  TestByFF
//
//  Created by hanxifeng on 16/6/17.
//  Copyright © 2016年 haixu. All rights reserved.
//

#import "FBtnArrow.h"
#define kPadding 10
#define KimgW 7
@implementation FBtnArrow

-(instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        self.imageView.contentMode = UIViewContentModeScaleAspectFit;
        [self setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
        self.titleLabel.font = [UIFont systemFontOfSize:13];
        self.layer.borderColor = [[UIColor blackColor] CGColor];
        self.layer.cornerRadius = 5;
        self.layer.borderWidth = 0.5;
    }
    return self;
}


-(CGRect)imageRectForContentRect:(CGRect)contentRect{
    
    CGFloat imgW = KimgW;
    CGFloat imgH = contentRect.size.height;
    CGFloat imgX = contentRect.size.width - imgW - kPadding;
    CGFloat imgY = 0;
    
    return CGRectMake(imgX, imgY, imgW, imgH);
}

-(CGRect)titleRectForContentRect:(CGRect)contentRect{
    
    CGFloat titleW = contentRect.size.width - KimgW - 3 * kPadding;
    CGFloat titleH = contentRect.size.height;
    CGFloat titleX = kPadding;
    CGFloat titleY = 0;
    
    return CGRectMake(titleX, titleY, titleW, titleH);
}

-(void)setTitle:(NSString *)title titleColor:(UIColor *)titleColor titleFont:(UIFont *)titleFont andImg:(UIImage *)img{
    [self setTitle:title forState:UIControlStateNormal];
    [self setTitleColor:titleColor forState:UIControlStateNormal];
    [self setImage:img forState:UIControlStateNormal];
    self.titleLabel.font = titleFont;
}

@end
